<template>
  <div :class="'video-box ' + (isMine ? 'my-video' : '')" :style="'background:#000 url('+this.message.payload.thumbUrl+') no-repeat center;background-size:auto 100%;'" @click="player">
    <i class="video-icon el-icon-video-play"></i>
    <div v-if="isPlay" class="play-video" @click.stop="isPlay=false">
      <video :src="this.message.payload.videoUrl" autoplay="autoplay" controls="controls"></video>
    </div>
  </div>
</template>

<script>
import {getVideoCover} from '@/utils/video'
export default {
  name: "MessageVideo",
  data() {
    return {
      isPlay: false,
      cover:'',
    };
  },

  components: {},
  props: {
    message: {
      type: Object,
      default: () => {}
    },
    isMine: {
      type: Boolean,
      default: true
    }
  },
  methods: {
    player() {
      this.isPlay=true;
    }
  }
}
</script>

<style lang="scss" scoped>
.video-message {}

.video-box {
  width: 160px;
  height: 120px;
  border-radius:2px 10px 10px 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  cursor: pointer;
}

.my-video {
  border-radius: 10px 2px 10px 10px;
}

.icon {
  position: absolute;
  transform: translate(-50%,-50%);
  top: 50%;
  left: 50%;
}

.video-icon {
  font-size: 28px;
  color: #fff;
}
.play-video{
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,.2);
  z-index: 9;
  video{
    width: 900px;
    height: 500px;
    position: fixed;
    transform: translate(-50%,-50%);
    top: 50%;
    left: 50%;
  }
}

</style>
